<template>
    <div>
        <div class="container">
            <div class="handle-box">
                <!-- <el-button type="primary"  class="handle-del mr10" @click="delAllSelection">批量删除</el-button> -->
                <el-form ref="form" :inline="true" :model="form">
                    <!-- <el-form-item>
                        <el-button type="primary" @click="handleAdd">新增</el-button>
                    </el-form-item> -->
                </el-form>
            </div>
            <el-table :data="tableData" border class="table" ref="multipleTable" header-cell-class-name="table-header">
                <el-table-column width="auto" label="code" align="center">
                    <template slot-scope="scope">{{ scope.row.code }}</template>
                </el-table-column>

                <el-table-column width="auto" label="名称" align="center">
                    <template slot-scope="scope">{{ scope.row.name }}</template>
                </el-table-column>

                <!-- <el-table-column width="auto" label="登录名" align="center">
                    <template slot-scope="scope">{{ scope.row.songTitle }}</template>
                </el-table-column>

                <el-table-column width="auto" label="状态" align="center">
                    <template slot-scope="scope">
                        <img
                            v-if="scope.row.status == 0"
                            style="width: 20px;height: 20px;"
                            src="@/assets/images/歌曲管理/u464.png"
                            alt=""
                        />
                        <img
                            v-else-if="scope.row.status == 1"
                            style="width: 20px;height: 20px;"
                            src="@/assets/images/歌曲管理/u468.png"
                            alt=""
                        />
                    </template>
                </el-table-column> -->

                <!-- <el-table-column width="auto" label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" @click="handleImplement(scope.$index, scope.row)">管理</el-button>
                    </template>
                </el-table-column> -->
            </el-table>

            <!-- <div class="pagination">
                <el-pagination
                    background
                    layout="total,sizes, prev, pager, next, jumper"
                    :page-sizes="[5, 10, 20, 30]"
                    @size-change="handleSizeChange"
                    :current-page="query.pageIndex"
                    :page-size="query.pageSize"
                    :total="pageTotal"
                    @current-change="handlePageChange"
                ></el-pagination>
            </div> -->
        </div>
    </div>
</template>

<script>
export default {
    name: 'TerminalType',
    data() {
        return {
            query: {
                address: '',
                name: '',
                pageIndex: 1,
                pageSize: 10
            },
            tableData: [],
            pageTotal: 0,
            form: {}
        };
    },
    // created() {
    //     this.getData();
    // },
    watch: {
        $route: {
            deep: true,
            immediate: true,
            handler(a, b) {
                console.log(a, b);
                if (a.name === 'MealManage') {
                    this.getData();
                }
            }
        }
    },
    methods: {
        async getData() {
            try {
                let url = '/channel/getTerminal';
                let { data: res } = await this.$http[4].get(url, {});
                console.log(res);
                if (res.code != '0000') {
                    throw new Error(res.message);
                }
                this.tableData = [];
                if (res.data && res.data.length > 0) {
                    for (var i = 0; i < res.data.length; i++) {
                        this.tableData.push({
                            name: res.data[i][i],
                            code: i
                        });
                    }
                }
            } catch (err) {
                console.log(err);
                this.$message.error({
                    message: err.message,
                    duration: 1500
                });
            }

            // this.tableData = [
            //     {
            //         id: 10010,
            //         songTitle: '张三',
            //         money: 123,
            //         address: '广东省东莞市长安镇',
            //         state: '成功',
            //         date: '2019-11-1',
            //         thumb: 'https://lin-xin.gitee.io/images/post/wms.png',
            //         status: '0'
            //     },
            //     {
            //         id: 10010,
            //         songTitle: '张三',
            //         money: 123,
            //         address: '广东省东莞市长安镇',
            //         state: '成功',
            //         date: '2019-11-1',
            //         thumb: 'https://lin-xin.gitee.io/images/post/wms.png',
            //         status: '1'
            //     }
            // ];
            // this.pageTotal = 1 || 0;
        }

        // handleAdd() {
        //     this.$router.replace({
        //         path: '/add_/user'
        //     });
        // },
        // 编辑操作
        // handleImplement(index, row) {
        //     this.$router.replace({
        //         path: '/album_3/info_2',
        //         query: {
        //             id: '444'
        //         }
        //     });
        // },
        // 保存编辑
        // saveEdit() {
        //     this.editVisible = false;
        //     this.$message.success(`修改第 ${this.idx + 1} 行成功`);
        //     this.$set(this.tableData, this.idx, this.form);
        // },
        // 分页导航
        // handlePageChange(val) {
        //     this.$set(this.query, 'pageIndex', val);
        //     this.getData();
        // },
        // handleSizeChange(val) {
        //     this.$set(this.query, 'pageSize', val);
        //     this.getData();
        // }
    }
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}

.handle-select {
    width: 120px;
}

.handle-input {
    /* width: 300px; */
    width: 69px;
    height: 28px;
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
</style>
